package com.yohann.designPattern.state;

/**
 * <p>
 * 颁奖状态
 * </p>
 *
 * @author Yohann
 * @since 2021/2/13 17:30
 */
public class Dispense implements State {
    private RaffleActivity activity;

    public Dispense(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    public void deductMoney() {
        System.out.println("不能抽奖");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }

    @Override
    public void dispensePrize() {
        if (activity.getCount() > 0) {
            System.out.println("你正在领奖");
            activity.setState(activity.getNoRaffle());
        } else {
            System.out.println("奖品已领完");
            activity.setState(activity.getDispenseOut());
        }
    }
}